package com.example.tfliteonwatch;
import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class setTime extends AppCompatActivity {

    private Button confirm;
    private EditText time;
    private int dur;
    private TextView text;
    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set_time);
        text=(TextView) findViewById(R.id.text) ;
        para.setTimeIndex=para.setTimeIndex+1;
        text.setText("第"+para.setTimeIndex+"/"+para.action.size()+"个动作 "+para.action.get(para.setTimeIndex-1));
        confirm=(Button) findViewById(R.id.timer_confirm);
        confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(dur<=0) {
                    Toast.makeText(getApplicationContext(),"请输入正确的时间",Toast.LENGTH_LONG).show();
                }
                else
                {

                    para.timelist.add(dur);
                    if(para.setTimeIndex!=para.action.size()){
                    Intent intent=new Intent(setTime.this, setTime.class);
                    startActivity(intent);
                   }
                    else{
//                        for(int i :para.timelist){
//                            Log.d("",i+" ");
//                        }
                        Intent intent=new Intent(setTime.this, chooseModel.class);
                        startActivity(intent);
                    }
                }
            }
        });
        time=(EditText)findViewById(R.id.btn_setTime);
        time.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                Log.d("time:", charSequence.toString());
                dur=Integer.parseInt(charSequence.toString());
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });
    }}


